
package com.yzkj.cpjxc.business.domain;

import com.yzkj.cpjxc.business.service.DicObjService;
import com.yzkj.cpjxc.business.framework.utils.ContextUtils;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class DictionaryConstants {

	
	public static String DT_CPPCC_IDENTITY = "DT_CPPCC_IDENTITY";//政协职务字典
	
	public static String DT_STATUS_QY = "1";//启用
	public static String DT_DELETE_ZC = "1";//正常
	public static String DT_STATUS_TY = "2";//停用
	public static String DT_DELETE_YSC = "-1";//已删除

	/**
	 * 字典组别类型
	 */
	public static Map<String, String> getDicTypeMap() {
		
		HashMap<String, String> map = new LinkedHashMap<String, String>();
		map.put(DT_CPPCC_IDENTITY, "政协职务字典");
		
		return map;
	}
	
	/**
	 * @description: 字典组别公共map
	 */
	public static Map<String, String> getDicGroupMap(String dicType) {
		try {
			HashMap<String, String> map = new LinkedHashMap<String, String>();
			DicObjService objService = (DicObjService) ContextUtils.getBean("dicObjService");
			List<DicObj> list = objService.getObjectList(dicType);
			for (int i = 0; i < list.size(); i++) {
				map.put(list.get(i).getDicCode(), list.get(i).getDicName());
			}
			return map;
		} catch (Exception e) {
			return null;
		}
	}
	
	public static Map<String, String> getDicGroupKeyByValueMap(String dicType) {
		try {
			HashMap<String, String> map = new LinkedHashMap<String, String>();
			DicObjService objService = (DicObjService) ContextUtils.getBean("dicObjService");
			List<DicObj> list = objService.getObjectList(dicType);
			for (int i = 0; i < list.size(); i++) {
				map.put(list.get(i).getDicName(), list.get(i).getDicCode());
			}
			return map;
		} catch (Exception e) {
			return null;
		}
	}
	
}
